﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Universum.Infrastructure.Configuration;
using System.Net.Mime;

namespace Universum.Model.Services
{
	public class ContentTypeRepresentationService
	{
		private static string[] presentable_content = new string[]{
			ConstantIdentifiers.FILETYPE_IMAGE_GIF,
			ConstantIdentifiers.FILETYPE_IMAGE_JPEG,
			ConstantIdentifiers.FILETYPE_IMAGE_JPG,
			ConstantIdentifiers.FILETYPE_IMAGE_PNG,
			ConstantIdentifiers.FILETYPE_TEXT_PLAIN,
			ConstantIdentifiers.FILETYPE_APPLICATION_PDF
													 };
		private static string[] image_content = new string[]{
			ConstantIdentifiers.FILETYPE_IMAGE_GIF,
			ConstantIdentifiers.FILETYPE_IMAGE_JPEG,
			ConstantIdentifiers.FILETYPE_IMAGE_JPG,
			ConstantIdentifiers.FILETYPE_IMAGE_PNG,
		};
		public static bool IsImageContent(string contentType)
		{
			return image_content.Contains(contentType);
		}
		public static bool IsPresentableContent(string contentType)
		{
			return presentable_content.Contains(contentType);
		}
		string _contentType;
		public ContentTypeRepresentationService(string contentType)
		{
			_contentType = contentType;
			ContentType ctype = new ContentType(contentType);
			switch(_contentType){
				case ConstantIdentifiers.FILETYPE_IMAGE_PNG:
				case ConstantIdentifiers.FILETYPE_IMAGE_JPG:
				case ConstantIdentifiers.FILETYPE_IMAGE_JPEG:
				case ConstantIdentifiers.FILETYPE_IMAGE_GIF:
				Path = new ContentDirectoryService(ConstantIdentifiers.image_icon).Path;
				break;
				case ConstantIdentifiers.FILETYPE_APPLICATION_ZIP:
				case ConstantIdentifiers.FILETYPE_APPLICATION_7ZIP:
				case ConstantIdentifiers.FILETYPE_APPLICATION_RAR:
				Path = new ContentDirectoryService(ConstantIdentifiers.zip_icon).Path;
				break;
				case ConstantIdentifiers.FILETYPE_APPLICATION_PDF:
					Path = new ContentDirectoryService(ConstantIdentifiers.pdf_icon).Path;
					break;
				case ConstantIdentifiers.FILETYPE_APPLICATION_MSWORD:
				case ConstantIdentifiers.FILETYPE_APPLICATION_MSWORD_DOCX:
					Path = new ContentDirectoryService(ConstantIdentifiers.word_icon).Path;
					break;
			}
		}
		public string Path { get;private set; }
	}
}
